class Solution:
    def getRow(self, rowIndex):
        # row = [1] * (rowIndex+1)
        # for i in range(2, rowIndex+1):
        #     for j in range(i-1,0,-1):
        #         row[j] += row[j-1]
        # return row
        triangle = []
        for i in range(rowIndex+1):
            row = [1] * (i+1)
            for j in range(1, len(row)-1):
                row[j] = triangle[i-1][j-1] + triangle[i-1][j]
            triangle.append(row)
        return triangle[rowIndex]
if __name__ == '__main__':
    s = Solution()
    print(s.getRow(3))
